using System;
using System.Collections.Generic;
using System.Text;
using Refly.CodeDom;
using Refly.CodeDom.Statements;
using Refly.CodeDom.Expressions;

namespace Doubler.Templates.Recorder.RecorderActions
{
    public class RecordParameters : RecorderActionBase
    {
        protected override void doAct(Refly.CodeDom.IClassDeclaration recorder
            , Refly.CodeDom.MethodDeclaration recorderMethod
            , Refly.CodeDom.Expressions.NativePropertyReferenceExpression recordingProperty
            , Reflector.CodeModel.ITypeReference subject
            , Reflector.CodeModel.IMethodDeclaration methodInformation)
        {
            foreach (ParameterDeclaration Parameter in recorderMethod.Signature.Parameters)
            {
                string PassedRecordingName = RecorderGenerator.GetPassedRecordingName(Parameter);
                Expression RecordPassed = recordingProperty.Prop(PassedRecordingName);
                Statement Assignment = Stm.Assign(RecordPassed, Expr.Arg(Parameter));
                recorderMethod.Body.Add(Assignment);
            }
        }
    }
}
